//package com.cdxy.controller;
//
//
//import com.cdxy.enums.mq.RabbitExchangeEnum;
//import com.cdxy.enums.mq.RabbitQueueEnum;
//import com.cdxy.enums.mq.RabbitRoutingKeyEnum;
//import com.cdxy.model.dto.base.controller.BaseController;
//import com.cdxy.model.dto.base.resp.ApiResponse;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.connection.CorrelationData;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.PostConstruct;
//import java.util.Date;
//
///**
// * <p>
// * 可维护字典信息 前端控制器
// * </p>
// *
// * @author autoGenCode
// * @since 2020-03-05
// */
//@RestController
//@RequestMapping("/dictionary")
//@Slf4j
//public class DictionaryController extends BaseController implements RabbitTemplate.ReturnCallback, RabbitTemplate.ConfirmCallback {
//
//    @Autowired
//    private RabbitTemplate rabbitTemplate;
//
//    @PostConstruct
//    public void init() {
//        // 消息队列事务
//        rabbitTemplate.setChannelTransacted(true);
//
//        rabbitTemplate.setConfirmCallback(this);
//        rabbitTemplate.setMandatory(true);
//
//        rabbitTemplate.setReturnCallback(this);
//
//    }
//
//    @PostMapping("/sendMq")
//    @ApiOperation(value = "发送消息队列", notes = "消息队列测试")
//    public ApiResponse sendMq(@Validated @RequestBody String body) {
//        rabbitTemplate.convertAndSend(RabbitExchangeEnum.BUSINESS.getCode(), RabbitRoutingKeyEnum.BUSINESS_QUEUE_A.getCode(), body);
//        return successApiResponse();
//    }
//
//    /**
//     * 延迟队列
//     * @param body
//     * @return
//     */
//
//    @PostMapping("/sendDelayMq")
//    @ApiOperation(value = "发送消息队列", notes = "消息队列测试")
//    public ApiResponse sendDelayMq(@Validated @RequestBody String body) {
//        if (body.equals("test")) {
//            log.info("发送延迟队列A：{}", new Date());
//            rabbitTemplate.convertAndSend(RabbitExchangeEnum.DELAY_BUSINESS.getCode(), RabbitQueueEnum.DELAY_BUSINESS_QUEUE_A.getRabbitRoutingKeyEnum().getCode(), body);
//        } else {
//            log.info("发送延迟队列B：{}", new Date());
//            rabbitTemplate.convertAndSend(RabbitExchangeEnum.DELAY_BUSINESS.getCode(), RabbitQueueEnum.DELAY_BUSINESS_QUEUE_B.getRabbitRoutingKeyEnum().getCode(), body);
//        }
//        return successApiResponse();
//    }
//
//    @Override
//    public void returnedMessage(Message message, int i, String s, String s1, String s2) {
//        // 消息未找到队列的分配
//    }
//
//    @Override
//    public void confirm(CorrelationData correlationData, boolean b, String s) {
//        // 每一次发送成功后的消息分配到队列上的回调
//    }
//}
